<template>
  <div>
    <div class="block">
      <button>添加角色</button>
    </div>
    <el-table :data="rolemanagement" height="530" border style="width: 100%">
      <el-table-column prop="id" label="编号" width="180"> </el-table-column>
      <el-table-column prop="name" label="角色名称" width="180">
      </el-table-column>
      <el-table-column prop="key" label="角色标识"> </el-table-column>
      <el-table-column prop="creator.nickname" label="创建者">
        <template v-slot="slot">
          <img :src="slot.row.creator.avatar" />
          <span>{{ slot.row.creator.nickname }}</span
          >| <span>{{ slot.row.creator.username }}</span>
        </template>
      </el-table-column>

      <el-table-column prop="created" label="创建时间">
        <template slot-scope="scope">
          <!-- addtime 是接口的字段 -->
          <!-- | 管道符 -->
          <!-- 设置全局过滤器 名为dateChage -->
          {{ scope.row.created | dateChage }}
        </template>
      </el-table-column>
      <el-table-column prop="updated" label="更新时间">
        <template slot-scope="scope">
          <!-- addtime 是接口的字段 -->
          <!-- | 管道符 -->
          <!-- 设置全局过滤器 名为dateChage -->
          {{ scope.row.updated | dateChage }}
        </template>
      </el-table-column>
      <el-table-column prop="" label="操作">
        <template>
          <el-link type="primary" class="el-icon-edit">编辑</el-link>&nbsp;
          <el-link type="danger" class="el-icon-delete">删除</el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
export default {
  name: "RoleManagement",
  computed: {
    ...mapState("role", ["rolemanagement"]),
  },
  methods: {
    ...mapActions("role", ["getRole"]),
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
  created() {
    this.getRole();
  },
  data() {
    return {};
  },
};
</script>
<style lang="scss" scoped>
button {
  color: white;
  margin: 10px;
  width: 80px;
  height: 40px;
  background-color: #409eff;
  border-radius: 2px;
}
img {
  width: 40px;
  height: 40px;
}
</style>
